package com.hualude.roadsign.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by shao-yikun on 2017/9/12.
 */
public class FormatNumber {
    public static String  resize(String number){
        String result=number;
        Integer pointPosition=number.indexOf(".");
        Integer numberLen=number.length();
        Integer gap=numberLen-pointPosition-1;
        for(;gap<6;gap++)
            result+="0";
        return result;
    }

    public static String getTime(){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String nowTime=df.format(new Date());
        return nowTime;
    }

    public static String transformDate(String time)throws Exception{
        String res;
        time=time.trim();
        SimpleDateFormat simpleDateFormat=null;
        if(time.length()>10)
            simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        else
            simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = simpleDateFormat.parse(time);
        long ts = date.getTime()/1000;
        res = String.valueOf(ts);
        return res;
    }


    public static StringBuilder createSql(AndFlag andFlag,String demo,String value){
        StringBuilder sql=new StringBuilder(" ");
        if(value!=null&&value.length()>0){
            if(!andFlag.getAndFlag()){
                andFlag.setAndFlag(true);
            }else {
                sql.append("and");
            }
            sql.append(demo).append(value);
        }
        return sql;
    }
    public static void main(String[] args){
        String  a="123";
        System.out.println(Integer.parseInt(a)+2);
    }

}
